# eric7.EricNetwork.EricTldExtractor

Module implementing the TLD Extractor.

### Global Attributes

_TLDExtractor

### Classes

EricTldExtractor | Class implementing the TLD Extractor.
EricTldHostParts | Class implementing the host parts helper.

### Functions

instance | Global function to get a reference to the TLD extractor and create it, if it hasn't been yet.

## EricTldExtractor

Class implementing the TLD Extractor.

Note: The module function instance() should be used to get a reference to a global object to avoid overhead.

### Derived from

QObject

### Class Attributes

None

### Class Methods

None

### Methods

EricTldExtractor | Constructor
__defaultDataSearchPaths | Private method to get the default search paths for the TLD data file.
__domainHelper | Private method to get the domain name without TLD.
__loadData | Private method to load the TLD data.
__normalizedHost | Private method to get the normalized host for a host address.
__parseData | Private method to parse TLD data.
__registrableDomainHelper | Private method to get the registrable domain (i.e.
__subdomainHelper | Private method to get the subdomain of a host address (i.e.
dataSearchPaths | Public method to get the search paths for the TLD data file.
domain | Public method to get the domain for a host.
getTldDownloadUrl | Public method to get the TLD data file download URL.
isDataLoaded | Public method to check, if the TLD data ia already loaded.
registrableDomain | Public method to get the registrable domain for a host.
setDataSearchPaths | Public method to set the search paths for the TLD data file.
splitParts | Public method to split a host address into its parts.
subdomain | Public method to get the subdomain for a host.
tld | Public method to get the top level domain for a host.

### Static Methods

None

#### EricTldExtractor (Constructor)

EricTldExtractor(withPrivate=False, parent=None)

Constructor

withPrivate (bool)
  flag indicating to load private TLDs as well
parent (QObject)
  reference to the parent object

#### EricTldExtractor.__defaultDataSearchPaths

__defaultDataSearchPaths()

Private method to get the default search paths for the TLD data file.

Return:
  default search paths for the TLD data file

Return Type:
  list of str

#### EricTldExtractor.__domainHelper

__domainHelper(host, tldPart)

Private method to get the domain name without TLD.

host (str)
  host address
tldPart (str)
  TLD part of the host address

Return:
  domain name

Return Type:
  str

#### EricTldExtractor.__loadData

__loadData()

Private method to load the TLD data.

#### EricTldExtractor.__normalizedHost

__normalizedHost(host)

Private method to get the normalized host for a host address.

host (str)
  host address to be normalized

Return:
  normalized host address

Return Type:
  str

#### EricTldExtractor.__parseData

__parseData(dataFile, loadPrivateDomains=False)

Private method to parse TLD data.

dataFile (str)
  name of the file containing the TLD data
loadPrivateDomains (bool)
  flag indicating to load private domains

Return:
  flag indicating success

Return Type:
  bool

#### EricTldExtractor.__registrableDomainHelper

__registrableDomainHelper(domainPart, tldPart)

Private method to get the registrable domain (i.e. domain plus TLD).

domainPart (str)
  domain part of a host address
tldPart (str)
  TLD part of a host address

Return:
  registrable domain name

Return Type:
  str

#### EricTldExtractor.__subdomainHelper

__subdomainHelper(host, registrablePart)

Private method to get the subdomain of a host address (i.e. domain part without the registrable domain name).

host (str)
  host address
registrablePart (str)
  registrable domain part of the host address

Return:
  subdomain name

Return Type:
  str

#### EricTldExtractor.dataSearchPaths

dataSearchPaths()

Public method to get the search paths for the TLD data file.

Return:
  search paths for the TLD data file

Return Type:
  list of str

#### EricTldExtractor.domain

domain(host)

Public method to get the domain for a host.

host (str)
  host name to get the domain for

Return:
  domain for host

Return Type:
  str

#### EricTldExtractor.getTldDownloadUrl

getTldDownloadUrl()

Public method to get the TLD data file download URL.

Return:
  download URL

Return Type:
  QUrl

#### EricTldExtractor.isDataLoaded

isDataLoaded()

Public method to check, if the TLD data ia already loaded.

Return:
  flag indicating data is loaded

Return Type:
  bool

#### EricTldExtractor.registrableDomain

registrableDomain(host)

Public method to get the registrable domain for a host.

host (str)
  host name to get the registrable domain for

Return:
  registrable domain for host

Return Type:
  str

#### EricTldExtractor.setDataSearchPaths

setDataSearchPaths(searchPaths=None)

Public method to set the search paths for the TLD data file.

searchPaths (list of str)
  search paths for the TLD data file or None, if the default search paths shall be set

#### EricTldExtractor.splitParts

splitParts(host)

Public method to split a host address into its parts.

host (str)
  host address to be split

Return:
  splitted host address

Return Type:
  EricTldHostParts

#### EricTldExtractor.subdomain

subdomain(host)

Public method to get the subdomain for a host.

host (str)
  host name to get the subdomain for

Return:
  subdomain for host

Return Type:
  str

#### EricTldExtractor.tld

tld(host)

Public method to get the top level domain for a host.

host (str)
  host name to get TLD for

Return:
  TLD for host

Return Type:
  str

Up

## EricTldHostParts

Class implementing the host parts helper.

### Derived from

None

### Class Attributes

domain
host
registrableDomain
subdomain
tld

### Class Methods

None

### Methods

None

### Static Methods

None

Up

## instance

instance(withPrivate=False)

Global function to get a reference to the TLD extractor and create it, if it hasn't been yet.

withPrivate (bool)
  flag indicating to load private TLDs as well

Return:
  reference to the zoom manager object

Return Type:
  EricTldExtractor

Up